home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_weap_thermdet_m.cog < prev    next >
Text File  |  1998-02-25  |  9KB  |  328 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # WEAP_THERMDET.COG
  4. #
  5. # WEAPON 4 Script - Thermal Detonator
  6. #
  7. # Fun to use and handy for clearing some elbow room.  Not recommending
  8. #  for those with noodle arms. The longer you hold down the fire key
  9. #  (CTRL/Z) the farther you throw the detonator.
  10. #
  11. # The primary fire throws the detonator with the 3 second delay, the
  12. #  secondary makes it explode on impact.
  13. #
  14. # - Not affected by MagSealed sectors/surfaces.
  15. #
  16. # [YB & CYW]
  17. #
  18. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  19. # ========================================================================================
  20.  
  21. symbols
  22.  
  23. model       povModel=detv.3do             local
  24. model       povModel_m=detv_m.3do         local
  25. model       weaponMesh=detg.3do           local
  26.  
  27. keyframe    mountAnim=detvmnt.key         local
  28. keyframe    dismountAnim=detvdis.key      local
  29. keyframe    povFireAnim=detvpst1.key      local
  30. keyframe    prePOVThrowAnim=detvpre1.key  local
  31. #keyframe   preThrowAnim=kyrthro0.key     local
  32. keyframe    holsterAnim=kyhlstr.key       local
  33.  
  34. template    projectile=+grenade1          local
  35. template    projectile1=+grenade2         local
  36. template    projectileB=+dudgrenade       local
  37.  
  38. sound       throwSound=ThermalThrow01.wav local
  39. sound       clickSound=ThermClick01.wav   local
  40. sound       clickSound2=ThermClick02.wav  local
  41. sound       loopSound=ThermLoop01.wav     local
  42.  
  43. flex        delayTime=1.0                 local
  44. flex        throwWait=0.8                 local
  45. flex        mountWait                     local
  46. flex        autoAimFOV=10                 local
  47. flex        autoAimMaxDist=5              local
  48. flex        holsterWait                   local
  49.  
  50. thing       player                        local
  51.  
  52. int         preThrowTrack                 local
  53. int         selectTrack                   local
  54. int         prePOVThrowTrack              local
  55. int         mode                          local
  56. int         cocked=0                      local
  57. int         holsterTrack                  local
  58.  
  59. int         selectMode=1                  local
  60.  
  61. message     startup
  62. message     activated
  63. message     deactivated
  64. message     selected
  65. message     deselected
  66. message     autoselect
  67. message     timer
  68. message     newplayer
  69. message     splash
  70.  
  71. end
  72.  
  73. # ========================================================================================
  74.  
  75. code
  76.  
  77. startup:
  78.    // Setup delays and variables.
  79.    mountWait    = GetKeyLen(mountAnim);
  80.  
  81.    preThrowTrack=-1;
  82.    selectTrack=-1;
  83.    prePOVThrowTrack=-1;
  84.  
  85.    Return;
  86.  
  87. # ........................................................................................
  88.  
  89. activated:
  90.    player = GetSourceRef();
  91.    mode = GetSenderRef();
  92.    if (mode > 1)
  93.       Return;
  94.  
  95.    PlaySoundThing(clickSound[mode], player, 1.0, -1.0, -1.0, 0x80);
  96.  
  97.    // Cock arm back for throw.
  98.    if(preThrowTrack == -1 && prePOVThrowTrack == -1)
  99.    {
  100.       prePOVThrowTrack = jkPlayPOVKey(player, prePOVThrowAnim, 1, 0x14);
  101.       preThrowTrack = PlayMode( player, 38 );
  102.       ActivateWeapon(player, 0, mode);
  103.    }
  104.    Return;
  105.  
  106. # ........................................................................................
  107.  
  108. deactivated:
  109.    player = GetSourceRef();
  110.    mode = GetSenderRef();
  111.  
  112.    delayTime = DeactivateWeapon(player, mode);        // allow activated messages again.
  113.  
  114.         // Don't throw if controls are disabled.
  115.    if (!(GetActorFlags(player) & 0x200000))
  116.     {
  117.         // Make sure both keys are up before continuing.
  118.         if (GetCurWeaponMode() != -1)
  119.             Return;
  120.     
  121.         // Set maximum scale factor (2 second hold.)
  122.         if(delayTime > 2)
  123.             delayTime = 2;
  124.     
  125.         // Set minimum scale factor
  126.         if(mode == 0)
  127.         {
  128.             if(delayTime < 0.7) delayTime = 0.7;
  129.         }
  130.         else
  131.         {
  132.             if(delayTime < 0.25) delayTime = 0.25;
  133.         }
  134.     
  135.         if(preThrowTrack != -1 && prePOVThrowTrack != -1)
  136.         {
  137.             jkStopPOVKey(player, prePOVThrowTrack, 0);
  138.             StopKey(player, preThrowTrack, 0);
  139.             preThrowTrack = -1;
  140.             prePOVThrowTrack = -1;
  141.         }
  142.     
  143.         if (GetInv(player, 93))
  144.         {
  145.             mode = 2;
  146.             SendMessageEx(GetThingClassCog(player), skill, 1100, 0, 0, 0);
  147.         }
  148.     
  149.         // Throw the appropriate detonator.
  150.         SetPOVShake('0.0 -.003 0.0', '0.5 0.0 0.0', .05, 40.0);
  151.         jkPlayPOVKey(player, povfireAnim, 1, 0x38);
  152.         PlaySoundThing(throwSound, player, 1.0, 0.5, 2.5, 0x80);
  153.         SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
  154.         FireProjectile(player, projectile[mode], -1, 15, '0.05 0 0', '0 0 0', delayTime, 0x1, 0.0, 0.0);
  155.         ChangeInv(player, 4, -1.0);
  156.         SetMountWait(player, throwWait);
  157.     
  158.         // If out of ammo try to autoswitch to another weapon
  159.         // if autoswitch is enabled else just switch to fists.
  160.         if(GetInv(player, 4) < 1)
  161.         {
  162.             if(GetAutoSwitch() & 1)
  163.             {
  164.                 SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
  165.             }
  166.             else
  167.             {
  168.                 SelectWeapon(player, 1);
  169.             }
  170.         }
  171.     }
  172.     else
  173.     {
  174.         if(preThrowTrack != -1 && prePOVThrowTrack != -1)
  175.         {
  176.             jkStopPOVKey(player, prePOVThrowTrack, 0);
  177.             StopKey(player, preThrowTrack, 0);
  178.             preThrowTrack = -1;
  179.             prePOVThrowTrack = -1;
  180.         }
  181.     }
  182.  
  183.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  184.    SetTimerEx(throwWait, 0, 0, 0);
  185.  
  186.    Return;
  187.  
  188. # ........................................................................................
  189.  
  190. timer:
  191.    if (GetSenderId() == 0)
  192.    {
  193.       // Start waggling after the throw.
  194.       jkSetWaggle(player, '10.0 7.0 0.0', 350);
  195.    }
  196.    else
  197.    if (GetSenderId() == 2)
  198.    {
  199.       StopKey(player, holsterTrack, 0.0);
  200.    }
  201.    Return;
  202.  
  203. # ........................................................................................
  204.  
  205. selected:
  206.    player = GetSourceRef();
  207.  
  208.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  209.  
  210.    // Play external mounting animation
  211.    PlayMode(player, 40);
  212.  
  213.    // Setup the meshes and models.
  214.     if (GetInv(player, 67) == 0.0)
  215.         jkSetPOVModel(player, povModel);        // Kyle hand
  216.     else
  217.         jkSetPOVModel(player, povModel_m);    // Mara Hand
  218.    SetArmedMode(player, 0);
  219.    jkSetWeaponMesh(player, weaponMesh);
  220.  
  221.    // Play the animation (NOLOOP + UNIQUE + ENDPAUSE).
  222.    // The animation is held at the last frame after it is played.
  223.    selectTrack = jkPlayPOVKey(player, mountAnim, 0, 0x14);
  224.    SetMountWait(player, GetKeyLen(mountAnim));
  225.  
  226.    // Clear Lightsaber flag, and enable activation messages.
  227.    jkClearFlags(player, 0x5);
  228.    SetCurWeapon(player, 4);
  229.    SetMountWait(player, GetKeyLen(mountAnim));
  230.  
  231.    Return;
  232.  
  233. # ........................................................................................
  234.  
  235. deselected:
  236.    player = GetSourceRef();
  237.  
  238.    jkPlayPOVKey(player, dismountAnim, 0, 18);
  239.  
  240.    holsterWait = GetKeyLen(holsterAnim);
  241.    SetMountWait(player, holsterWait);
  242.    holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
  243.    SetTimerEx(holsterWait, 2, 0.0, 0.0);
  244.    if(selectTrack != -1)
  245.    {
  246.       jkStopPOVKey(player, selectTrack, 0);
  247.       selectTrack = -1;
  248.    }
  249.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  250.    KillTimerEx(0);
  251.  
  252.    if(preThrowTrack != -1 && prePOVThrowTrack != -1)
  253.    {
  254.       jkStopPOVKey(player, prePOVThrowTrack, 0);
  255.       StopKey(player, preThrowTrack, 0);
  256.       preThrowTrack = -1;
  257.       prePOVThrowTrack = -1;
  258.    }
  259.  
  260.    Return;
  261.  
  262. # ........................................................................................
  263.  
  264. autoselect:
  265.    selectMode = GetSenderRef();
  266.    player = GetSourceRef();
  267.  
  268.    // If the player has ammo
  269.    if(GetInv(player, 4) != 0)
  270.    {
  271.  
  272.       // query for ammo
  273.       if(selectMode == -1)
  274.       {
  275.          ReturnEx(400.0);
  276.          Return;
  277.       }
  278.  
  279.       if((selectMode == 0) && !(GetAutoPickup() & 2))
  280.       {
  281.          ReturnEx(400.0);
  282.          Return;
  283.       }
  284.  
  285.       if((selectMode == 1) && !(GetAutoSwitch() & 2))
  286.       {
  287.          ReturnEx(400.0);
  288.          Return;
  289.       }
  290.  
  291.       if((selectMode == 2) && !(GetAutoPickup() & 2))
  292.       {
  293.          ReturnEx(400.0);
  294.          Return;
  295.       }
  296.  
  297.       ReturnEx(-2.0);
  298.       Return;
  299.  
  300.    }
  301.    else
  302.    {
  303.       ReturnEx(-1.0);
  304.    }
  305.  
  306.    Return;
  307.  
  308. # ........................................................................................
  309.  
  310. newplayer:
  311.    if(preThrowTrack != -1 && prePOVThrowTrack != -1)
  312.    {
  313.       jkStopPOVKey(player, prePOVThrowTrack, 0);
  314.       StopKey(player, preThrowTrack, 0);
  315.       preThrowTrack = -1;
  316.       prePOVThrowTrack = -1;
  317.    }
  318.    Return;
  319.  
  320. # ........................................................................................
  321.  
  322.  
  323. end
  324.  
  325.  
  326.  
  327.  
  328.